<?php

namespace app\controller;

use app\model\AdminModel;
use think\facade\Db;
use think\annotation\route;

class AdminController
{
    /**
     * @route ("getThisAdmin")
     * @param $id
     * @param $password
     * @param $libraryId
     * @return \think\response\Json
     */
    public function getThisAdmin($id, $password, $libraryId)
    {
        //获得结果集
        $now = AdminModel::where("password", $password)->find($id);
        if($now == null)return 0;
        $librarys = $now->librarys;
        $ret = false;
//        echo $librarys;
        foreach ($librarys as $index=>$value){
//            echo $value['libraryId'];
            if($value['libraryId'] == $libraryId)return json(AdminModel::find($id));
        }
        return 0;
    }

    /**
     * @route ("testGet")
     * @param $id
     * @return bool
     */
    public function testGet($id)
    {
        return json(AdminModel::field("imgUrl")->find($id));
    }
}